<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Design Pattern</title>
    <meta name="language" content="en" />
    <!--myInjectedScript-->
</head>
<body>
    <h1>
        Proxy</h1>
    <div class="section">
        <h2>
            Intent</h2>
        <p>
            Provide a surrogate or placeholder for another object to control access to it.<br />
        </p>
    </div>
    <div class="section">
        <h2>
            Also known as</h2>
        <p>
            Surrogate</p>
    </div>
    <div class="section">
        <h2>
            Motivation</h2>
        <p>
            One reason for controlling access to an object is to defer the full cost of its
            creation and initialization until we actually need to use it.
            <br />
            <a href="http://en.wikipedia.org/wiki/Proxy_pattern" target="_blank">Online resources</a>
        </p>
    </div>
    <div class="section">
        <h2>
            Applicability</h2>
        <p>
            Proxy is applicable whenever there is a need for a more versatile or sophisticated
            reference to an object than a simple pointer.
            <br />
            Here are several common situations in which the Proxy pattern is applicable:
            <ol>
                <li>A <b>remote proxy</b> provides a local representative for an object in a different
                    address space.</li>
                <li>A <b>virtual proxy</b> creates expensive objects on demand.</li>
                <li>A <b>protection proxy</b> controls access to the original object. Protection proxies
                    are useful when objects should have different access rights.</li>
                <li>A <b>smart reference</b> is a replacement for a bare reference that performs additional
                    actions when an object is accessed.</li>
            </ol>
        </p>
    </div>
    <div class="section">
        <h2>
            Class Diagram</h2>
        <p>
            <img alt="Diagram" src=" proxy.png" border="0" />
        </p>
    </div>
    <div class="section">
        <h2>
            Collaborations</h2>
        <p>
            Proxy forwards requests to RealSubject when appropriate, depending on the kind of
            proxy.<br />
        </p>
    </div>
    <div class="section">
        <h2>
            Consequences</h2>
        <p>
            The Proxy pattern introduces a level of indirection when accessing an object. The
            additional indirection has many uses, depending on the kind of proxy:</p>
        <ol>
            <li>A remote proxy can hide the fact that an object resides in a different address space.</li>
            <li>A virtual proxy can perform optimizations such as creating an object on demand.</li>
            <li>Both protection proxies and smart references allow additional housekeeping tasks
                when an object is accessed.</li>
        </ol>
        </p>
    </div>
    <div class="section">
        <h2>
            Related Patterns</h2>
        <p>
            <ul>
                <li><a href="">Adapter</a>: An adapter provides a different interface to the object it adapts.
                </li>
                <li><a href="">Decorator</a>: Although decorators can have similar implementations as proxies, decorators
                    have a different purpose. A decorator adds one or more responsibilities to an object,
                    whereas a <a href="">proxy</a> controls access to an object. </li>
            </ul>
        </p>
    </div>
</body>
</html>
